package org.xandroid.component;

import org.xandroid.util.X;
import org.xandroid.util.XToastHelper;

import android.app.Activity;
import android.content.Intent;
import android.view.Window;
import android.view.WindowManager;

/**
 * extensional activity in XAndroid Plan
 * @author Kross(krossford@foxmail.com)
 * @date 2014-3-10 18:34:51
 * */
public class XActivity extends Activity {
	
	/**
	 * show a toast message
	 * @param resId string resrouce id in R.java
	 * */
	protected void toast(int resId) {
		XToastHelper.show(this, resId);
	}
	
	/**
	 * show a toast message
	 * @param content message content
	 * */
	protected void toast(String content) {
		XToastHelper.show(this, content);
	}
	
	/**
	 * just start another activity
	 * @param targetActivity target activity
	 * */
	protected void jumpToActivity(Class<?> targetActivity) {
		startActivity(new Intent(this, targetActivity));
	}
	
	/**
	 * 设置当前Activity显示模式
	 * @param screenModel 参数值在X.ScreenModel中
	 * @date 2014-3-26 15:53:39
	 * */
	protected void setScreenModel(int screenModel) {
		boolean isFullScreen = false;
		boolean isNoTitle = false;
		
		switch (screenModel) {
		case X.ScreenModel.FULL_SCREEN:
			isFullScreen = true;
			break;
		case X.ScreenModel.NO_ACTION_BAR:
			isNoTitle = true;
			break;
		case X.ScreenModel.NO_ACTION_BAR_AND_FULL_SCREEN:
			isFullScreen = true;
			isNoTitle = true;
			break;
		}
	
		if (isFullScreen) {
			getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN );
		}
		if (isNoTitle) {
			requestWindowFeature(Window.FEATURE_NO_TITLE);
		}
	}
}